#!/bin/sh

if [ "$1" = "clean" ]; then
	# rm ./out/*.bin *.img  log.bochsrc.disk
	find -type f -regex ".*\.o\|.*\.bin\|.*\.img\|.*log\.bochsrc\.disk\|.*\.img\.lock"  -delete	
	exit 0
fi


if [ ! -d "./out" ]; then
      mkdir out
fi


if [ ! -e "hd.img" ]; then
     /usr/bin/bximage -hd=1 -mode="create" -q hd.img
fi


nasm -I include/ -o ./out/mbr.bin mbr.S && dd if=./out/mbr.bin of=./hd.img bs=512 count=1  conv=notrunc
nasm -I include/ -o ./out/loader.bin loader.S && dd if=./out/loader.bin of=./hd.img bs=512 count=4 seek=2 conv=notrunc
